<?php

namespace App\Http\Controllers\Api;

use App\Helpers\ApiHelper;
use App\Http\Controllers\Controller;
use App\Http\Requests\Api\InfoContent;
use App\Models\Articles;
use App\Models\Type;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class InfoController extends Controller
{
    public function content(InfoContent $request){
        $data = $request->validated();
        $article = Articles::where('articles.name', trim($data['article_name']))->join('types as t', 'articles.type_id', '=' , 't.id')->where('t.title', trim($data['type_name']))->select('articles.value')->first();
        $article = $article ? json_decode($article->value, true) : "";
        return ApiHelper::api_return($article ? 200 : 301, $article ? '获取数据成功' : '未获取数据', $article);

    }
}
